package weibo4j.model;
import weibo4j.org.json.JSONException;
import weibo4j.org.json.JSONObject;


public class Annotation {

	private Place place;
	private String mblogid;
	
	public Annotation(JSONObject json) throws JSONException {
			if (!json.isNull("place")) {
				place = new Place(json.getJSONObject("place"));
			}
			this.mblogid = json.getString("client_mblogid");
	}
	
	public Annotation(String json) throws JSONException {
		JSONObject anno = new JSONObject(json);
		if (!anno.isNull("place")) {
			place = new Place(anno.getJSONObject("place"));
		}
		this.mblogid = anno.getString("client_mblogid");
}
	
	public Place getPlace() {
		return place;
	}
	public void setPlace(Place place) {
		this.place = place;
	}
	public String getMblogid() {
		return mblogid;
	}
	public void setMblogid(String mblogid) {
		this.mblogid = mblogid;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((mblogid == null) ? 0 : mblogid.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Annotation other = (Annotation) obj;
		if ( !place.equals(((Annotation)obj).getPlace()))
			return false;
		if (mblogid != other.mblogid)
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "Annotation [Place=" + place.toString() + ", client_mblogid=" + mblogid + "]";
	}
	
}
